package com.unionftech.content_login.manager

import com.unionftech.baselibrary.network.RetrofitClient
import com.unionftech.content_login.api.LoginApi
import com.unionftech.content_login.api.RegisterApi

class ApiManager private constructor() {
    private lateinit var loginApi: LoginApi
    private lateinit var registerApi: RegisterApi

    companion object {
        @Volatile
        private var instance: ApiManager? = null

        @JvmStatic
        fun getInstance() = instance ?: synchronized(this) {
            instance ?: ApiManager().also {
                instance = it
            }
        }
    }

    fun apiLogin(): LoginApi {
        if (!::loginApi.isInitialized) {
            loginApi = RetrofitClient.getInstance().create(LoginApi::class.java)
        }
        return loginApi
    }

    fun apiRegister(): RegisterApi {
        if (!::registerApi.isInitialized) {
            registerApi = RetrofitClient.getInstance().create(RegisterApi::class.java)
        }
        return registerApi
    }
}